﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Common;
using System.Text.RegularExpressions; 
namespace DemoGeometry
{
    public partial class TCheckListControl : UserControl
    {
        Connecttion con ;
        public TCheckListControl()
        {
            InitializeComponent();
         
        }
        const int  TW = 0,ML = 1,XL = 1,HX = 2,TZ = 3,FW = 4;
        private DataTable  ASCB;
        private DataTable DrawSCB;
        private DataTable XseDt;
        private DataTable HourDt;
        private string _title;
        private string _xm;
        private string _nl;
        private string _xb;
        private string _ks;
        private string _ch;
        private string _ryrq;
        private string _zyhm;
        public bool drawb = false;
        public string title
        {
            get
            {
                _title = this.hospital.Text;
                return _title;
            }
            set
            {
                this.hospital.Font = new Font("宋体",20);

                this.hospital.Text = value;          
            }
        }

        public string xm
        {
            get
            {
                _xm = this.txm.Text;
                return _xm;
            }
            set
            {
                this.txm.Text = value;
            }
        }
        public string nl
        {
            get
            {
                _nl = this.tnl.Text;
                return _nl;
            }
            set
            {
                this.tnl.Text = value;
            }

        }
        public string xb
        {
            get
            {
                _xb = this.txb.Text;
                return _xb;
            }
            set
            {
                this.txb.Text = value;
            }

        }
        public string ks
        {
            get
            {
                _ks = this.tks.Text;
                return _ks;
            }
            set
            {
                this.tks.Text = value;
            }
        }
        public string ch
        {
            get
            {
                _ch = this.tch.Text;
                return _ch;
            }
            set
            {
                this.tch.Text = value;
            }
        }
        public string ryrq
        {
            get
            {
                _ryrq = this.tryrq.Text;
                return _ryrq;
            }
            set
            {
                this.tryrq.Text = value;
            }
        }
        public string zyhm
        {
            get
            {
                _zyhm = this.tzyhm.Text;
                return _zyhm;
            }
            set
            {
                this.hospital.Text = value;
            }

        }
  
        ///数据绘制脚本变量
        ///
  bool BColor=true;          //绘图方式：是否彩色
  float  Header_TopY;          //上表格起始y坐标
  float Header_CellHeight = 20;    //上表格单元格高度 GridHeight
  float Footer_TopY;          //下表格起始y坐标
  float Footer_CellHeight;    //下表格单元格高度
  float TopX = 35;              //画图起始0点座标
  float TopY = 200;         //画图起始0点座标
  float ShiftX = 100;       //左边空距
  float CellWidth = 14;     //每格单元(最小单元格)宽度
  float CellHeight = 14;    //每格单元(最小单元格)宽度高度
  float Width = 688;         //宽度
  float height = 875;        //高度
  float Title_height = 20;   //Title高度
  float Trail_height = 26;  //trail高度
  float TWBase = 34;           //体温在表格基线起点值
  float TWStep = 0.2f;          //每格数据值步长
  float MLBase = 20;           //脉捕/心率
  float MLStep = 4;            //每格数据值步长
  float NMaxML = 180;          //最大脉捕值
  float HXBase = 10;           //呼吸
  float HXStep = 2;            //每格数据值步长
  float NMinHX = 10;           //最小呼吸值
  float TZBase = 1000;         //体重
  float TZStep = 500;          //每格指最小的一格
  bool TWDraw=true;          //是否绘制体温点
  bool MLDraw=true;          //是否绘制脉博点
  bool HXDraw=false;         //是否绘制心率点
  bool TZDraw=false;         //是否绘制体重点
  int PrnStartDay=1;         //续打日期（从该日期开始打印）
  int AdjustColumnWidth=0;  //修正每大列宽度(每大列宽度与其内小格宽合计的差值)
  bool EqualLine= false;     //相邻两次数据值相等时是否连线
  bool ZKLine= false;         //转科是否连线
  string DontLineS="请假;外出;拒测";  //断开连线的说明情况字符，用;号分开多个
  int HXQBase=10;            //呼吸器显示坐标位置
  bool HXQDrawFS=true;        //三测表呼吸器绘制方式//0:固定值；1：随呼吸值动
  bool BTopTextTransparent=true; //顶部文字是否透明
  bool BTopTextScal=true;     //三测表顶部说明文字是否缩放显示在40度以内(打印不受此参数限制)
  bool BRGDMCLFS=true;
  bool XLQDrawEllipse=true;  //心率启搏器的绘制是否画圆圈
  bool HXQDrawEllipse=true; //呼吸器的绘制是否画圆圈
  RectangleF rectf;
  Color HeaderColor= Color.Blue;    //上部表格颜色
  Color FooterColor= Color.Blue;    //上部表格颜色
  Color TopTextColor=Color.Black;    //时间说明文字颜色
  Color BottomTextColor=Color.Black; //特殊情况文字颜色
  Color TrailColor=Color.Red;       //trail表格文字颜色
  Color TZColor=Color.Red ;         //体重连线颜色
  Color TWColor=Color.Blue;         //体温连线颜色
  Color HXColor=Color.Blue;         //呼吸连线颜色
  Color MBColor=Color.Red;         //脉搏连线颜色
  float TmpWdth = 8;            //图片大小宽度  （6）
  int IHT  = 4;             //画线、圆的大小 建议不要小于4
  int IHT1  = 2;             //第二次画线、圆的大小 建议不要小于2且不能大于
  int li_totalpage, li_currentpage=1;
  bool bxml = true;
  public void ConnectDb(string ls_connect)
  {
      con = new Connecttion("yxhis");
  }
/// <summary>
/// 取打印颜色
/// GetPrnColor
/// </summary>
/// <param aColor="e"></param>
private Color GetPrnColor(Color aColor)
{
  if (BColor) 
    return  aColor;
  else
    return Color.Black;
}

private bool IsNumeric(string value) 

{

    if (value == "")
        return false;
    else
        return Regex.IsMatch(value, @"^[+-]?\d*[.]?\d*$"); 

} 
     private void GetData(string ls_zyhm)
    {
       string ls_sql;
       DataSet ds;
         if(bxml)
         {
           
             XMLProcess xml = new XMLProcess("tbscbjl.xml");
             ds = xml.GetDataSetByXml("tbscbjl.xml");
             DrawSCB = ds.Tables[0];
             ds = xml.GetDataSetByXml("tb24dy.xml");
             HourDt = ds.Tables[0];
             ds = xml.GetDataSetByXml("tbxsexx.xml");
             XseDt = ds.Tables[0];
         }
         else
         {
         ls_sql = string.Format("select * from YSGZZ..TBSCBJLBQ307 where czyh='{0}' order by drq",ls_zyhm);
         con.getcommand(ls_sql);
         DrawSCB = con.readdatatable();
         li_totalpage = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(DrawSCB.Rows.Count) / 7.0M));
         if (li_totalpage == 1) li_currentpage = 1;
         ls_sql = string.Format("select cxsebh,cxsexm+'   '+cxsebh cxsexm from tbxsexx  where ccfzyh='{0}' union all Select '','产妇'", ls_zyhm);
         con.getcommand(ls_sql);
         XseDt = con.readdatatable();
         ls_sql = string.Format("select * from YSGZZ..TB24DY order by ixh");
         con.getcommand(ls_sql);
         HourDt = con.readdatatable();
         }

    }
        private void GetDataFromXML()
     {
         DataSet ds;
         XMLProcess xml = new XMLProcess("tbscbjl.xml");
         ds = xml.GetDataSetByXml("tbscbjl.xml");
         DrawSCB = ds.Tables[0];
         ds = xml.GetDataSetByXml("tb24dy.xml");
         HourDt = ds.Tables[0];
         ds = xml.GetDataSetByXml("tbxsexx.xml");
         XseDt = ds.Tables[0];
     }
     private void GetASCBData(string ls_zyhm, string ls_bh)
     {
         DataSet ds;
         DataView dv;
         XMLProcess xml = new XMLProcess("tbscbmxjl.xml");
         if (bxml)
         {
             ds = xml.GetDataSetByXml("tbscbmxjl.xml");
             dv = ds.Tables[0].AsDataView();
          //   if (string.IsNullOrEmpty(dv.RowFilter))
             dv.RowFilter=string.Format("czyh ='{0}' and cbh ='{1}'",ls_zyhm,ls_bh);
             ASCB = dv.ToTable();
             return;
         }
         else
         {
             string ls_sql = string.Format(@"select b.CBH,b.CZYH,b.CJLHSMC,b.CJLHSBM,b.CXM,b.CXB,b.NNL,b.DRYSJ,b.DCYSJ,b.DRQ,b.CBQBM,b.CBQMC,b.CCHBM,b.CCHMC,b.CZDMC,b.CZYKSMC,b.DJLSJ,b.IXBL,b.CXBCS,b.CDBCS,b.CDBL,b.NYLL,b.NCLQT,b.IYRL,b.ISRL,b.NSZY,b.NSSY,b.CXYDW,b.NTZ,b.NQT,b.ISG,b.CXBDW,b.ISTATUS,b.NSSY2,b.NSZY2,b.NSSY3,b.NSZY3,b.NSSY4,b.NSZY4
                        ,b.CTSZL,b.CCLQT1,b.CCLQT2,b.CCLQT1sm,b.CCLQT2sm,b.IFW
                        ,b.CSZ,b.CST,b.CST2,b.CZD1,B.CZD2,B.CZD3,B.CZD4
                        ,a.IJLLB,a.NTW,a.CTWCLFF,a.IML,a.IXL,a.IHX,a.ITT,a.IZT,a.IHQ,a.NWLJW,a.NFSTW,a.BXZQBQ,a.IQBQPL,a.BHXQ,a.CTSQK,a.DSSRQ,a.CSJSM,a.CTTFF 
                        from YSGZZ..TBSCBJLBQ307 b 
                        full join YSGZZ..TBSCBMXJLBQ307 a on a.cbh=b.cbh and a.ijllb > 0 
                        where b.czyh='{0}' and b.CBH='{1}'
                        order by b.drq,a.ijllb", ls_zyhm, ls_bh);
             con.getcommand(ls_sql);
             ASCB = con.readdatatable();
         }
     }
    
private string GetSCBNumStr(float num,string ls_flag,float value)
{
    string ls_ret;
    if(ls_flag=="XYDICT")
    {
        ls_ret = Convert.ToString(num * value);
    }
    else
    {
        ls_ret = Convert.ToString(num * value);
    }
    return ls_ret;
}

private void ValueToPoint(float Value, float Index, int Flag, ref float x, ref float y)
        {
  float base_1, step;
  int w,h;
 switch(Flag)
 {
   case  0:
    base_1 =TWBase;
    step = TWStep;
         break;
  case 1:

    base_1 = MLBase;
    step = MLStep;
    break;
  case 2:
    base_1 = HXBase;
    step = HXStep;
    break;
  case 3:
    base_1 = TZBase;
    step = TZStep;
    break;
  default :
    base_1 = TWBase;
    step = TWStep;
    break;
 }
      x = TopX+ShiftX + CellWidth*Index + CellWidth / 2 ;
  if (Flag== 4)
    x = TopX+ShiftX + CellWidth*Index + CellWidth;
    if (step == 0) return;
    //y = {TopY+height-Trail_height}height - (Value-base)/step*CellHeight;
    y = height - (Value - base_1) / step * CellHeight;
    }
        private void  GetPHX(Graphics g, float Value,float Index,int Flag)
    {

  
       float x,y,w,h,SCPointY=0.0f;
       float SCPointX=0.0f;
       Pen pen_1 = new Pen(Color.Black, 1);
       ValueToPoint(Value, Index, Flag, ref SCPointX, ref SCPointY);
      //IMage.DrawEllipse(SCPointX)-IHT,SCPointY)-IHT,SCPointX)+IHT,SCPointY)+IHT,psSolid,1,clWindowText,clWindowText);
       g.DrawEllipse(pen_1, SCPointX - IHT, SCPointY - IHT, SCPointX + IHT, SCPointY + IHT);
  }
        private void GetPHXMB(Graphics g, float Value,float Index,int Flag)
    {
     Pen  penred =new Pen(Color.Red);
     Pen penblue = new Pen(Color.Blue);
      float SCPointX=0.0f,SCPointY=0.0f;
      ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
       g.DrawEllipse(penred,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
       g.DrawEllipse(penblue,SCPointX - IHT1, SCPointY - IHT1, SCPointX + IHT1, SCPointY + IHT1);
   }

        private void GetPHXTW(Graphics g, float Value, float Index, int Flag)
    {
             float SCPointX=0.0f,SCPointY=0.0f;
             Pen penblue = new Pen(Color.Blue);
             ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
             g.DrawEllipse(penblue,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT) ;
    }

        private void GetPMB(Graphics g, float Value, float Index, int Flag)
       {
         float x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
         Brush brush = new SolidBrush(Color.Red);
         Pen  penred =new Pen(brush,4);
        ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
        //g.DrawEllipse(penred,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
        g.DrawEllipse(penred, SCPointX - IHT, SCPointY - IHT, IHT, IHT);
       }
        private void GetPXL(Graphics g, float Value, float Index, int Flag)
      {
          Pen  penred =new Pen(Color.Red);
          float  x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
          ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
          g.DrawEllipse(penred,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
       }
        private void GetPTWKL(Graphics g, float Value, float Index, int Flag)
     {
          float x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
          Pen penblue = new Pen(Color.Blue);
          ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
          g.DrawEllipse(penblue,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
     }
        private void GetPTWKLO(Graphics g, float Value, float Index, int Flag)
    {

       GetPHXMB( g,Value,Index,Flag);
    }
        private void GetPTWKLX(Graphics g, float Value, float Index, int Flag)
    {
         float x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
         ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
         Pen  penred =new Pen(Color.Red);
         Pen penblue = new Pen(Color.Blue);
         g.DrawEllipse(penred,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
         g.DrawEllipse(penblue,SCPointX-IHT1,SCPointY-IHT1,SCPointX+IHT1,SCPointY+IHT1);
    }
        private void GetPTWYW(Graphics g, float Value, float Index, int Flag)
    {
         GetPXL(g,Value,Index,Flag);
    }
        private void GetPTWYWO(Graphics g, float Value, float Index, int Flag)
 {
        float x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
        Pen  penred =new Pen(Color.Red);
        ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
        g.DrawEllipse(penred,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
        g.DrawEllipse(penred ,SCPointX-IHT1,SCPointY-IHT1,SCPointX+IHT1,SCPointY+IHT1);
 }
        private void GetPTWYWX(Graphics g, float Value, float Index, int Flag)
    {
      float x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
      Pen  penred =new Pen(Color.Red);
      ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
      g.DrawEllipse(penred,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
      g.DrawEllipse(penred,SCPointX-IHT1,SCPointY-IHT1,SCPointX+IHT1,SCPointY+IHT1);
    }
        private void GetPTWYX(Graphics g, float Value, float Index, int Flag)
    {
      float SCPointX=0.0f,SCPointY=0.0f;
      Pen  penblue =new Pen(Color.Blue);
      ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
      g.DrawLine(penblue,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
      g.DrawLine(penblue,SCPointX-IHT,SCPointY+IHT,SCPointX+IHT,SCPointY-IHT);
    }
        private void GetPTWYXO(Graphics g, float Value, float Index, int Flag)
    {
      float  x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
      Pen  penblue =new Pen(Color.Blue);
      Pen  penred =new Pen(Color.Red);
      ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
      g.DrawEllipse(penred,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
      g.DrawLine(penblue,SCPointX-IHT1,SCPointY-IHT1,SCPointX+IHT1,SCPointY+IHT1);
      g.DrawLine(penblue,SCPointX-IHT1,SCPointY+IHT1,SCPointX+IHT1,SCPointY-IHT1);
    }
        private void GetPTWYXX(Graphics g, float Value, float Index, int Flag)
    {
      float x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
      Pen  penblue =new Pen(Color.Blue);
      Pen  penred =new Pen(Color.Red);
      ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
      g.DrawEllipse(penred,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
      g.DrawLine(penblue,SCPointX-IHT1,SCPointY-IHT1,SCPointX+IHT1,SCPointY+IHT1);
      g.DrawLine(penblue,SCPointX-IHT1,SCPointY+IHT1,SCPointX+IHT1,SCPointY-IHT1);
    }
        private void GetPTWZC(Graphics g, float Value, float Index, int Flag)
    {
        float x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
      Pen  penblue =new Pen(Color.Blue);
      Pen  penred =new Pen(Color.Red);
      ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
      g.DrawEllipse(penblue,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
    }
        private void GetPTWZCO(Graphics g, float Value, float Index, int Flag)
{
       float x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
      Pen  penblue =new Pen(Color.Blue);
      Pen  penred =new Pen(Color.Red);
      ValueToPoint(Value, Index, Flag, ref SCPointX, ref SCPointY);
      g.DrawEllipse(penred,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
      g.DrawEllipse(penblue,SCPointX-IHT1,SCPointY-IHT1,SCPointX+IHT1,SCPointY+IHT1);
}
        private void GetPTWZCX(Graphics g, float Value, float Index, int Flag)
{
       float x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
      Pen  penblue =new Pen(Color.Blue);
      Pen  penred =new Pen(Color.Red);
      ValueToPoint(Value,Index,Flag,ref SCPointX,ref SCPointY);
      g.DrawEllipse(penred,SCPointX-IHT,SCPointY-IHT,SCPointX+IHT,SCPointY+IHT);
      g.DrawEllipse(penblue,SCPointX-IHT1,SCPointY-IHT1,SCPointX+IHT1,SCPointY+IHT1);
}

  private void DrawPoint(Graphics g, float Value,float Index,int Flag,string ResString,float ShiftX=0,float ShiftY=0)
    {
        float x,y,w,h,SCPointX=0.0f,SCPointY=0.0f;
   if(ResString=="") 
          return;
      if (ResString.ToUpper()=="phx".ToUpper()) 
          GetPHX(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="phxmb".ToUpper())
          GetPHXMB(g,Value,Index,Flag);
      else if  (ResString.ToUpper()=="phxtw".ToUpper())
          GetPHXTW(g,Value,Index,Flag);
      else if  (ResString.ToUpper()=="pmb".ToUpper())
          GetPMB(g,Value,Index,Flag);
      else if  (ResString.ToUpper()=="pxl".ToUpper())
          GetPXL(g,Value,Index,Flag);
      else if  (ResString.ToUpper()=="ptwkl".ToUpper())
          GetPTWKL(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwklo".ToUpper())
          GetPTWKLO(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwklx".ToUpper())
          GetPTWKLX(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwyw".ToUpper())
          GetPTWYW(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwywo".ToUpper())
          GetPTWYWO(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwywx".ToUpper())
          GetPTWYWX(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwyx".ToUpper())
          GetPTWYX(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwyxo".ToUpper())
          GetPTWYXO(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwyxx".ToUpper())
          GetPTWYXX(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwzc".ToUpper())
          GetPTWZC(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwzco".ToUpper())
          GetPTWZCO(g,Value,Index,Flag);
      else if (ResString.ToUpper()=="ptwzcx".ToUpper())
          GetPTWZCX(g,Value,Index,Flag);
      else
            MessageBox.Show("未定义["+ResString+"]类型的图！请先定义！");
      return;
  }
//画线
private void  DrawLine(Graphics g, float ValueS,float ValueE,int IndexS,int IndexE,int Flag,Color color)
    {
        float aPointX=0.0f,aPointY=0.0f;
        float bPointX=0.0f,bPointY=0.0f;
        //Pen  pen = new Pen(color,1);
         Pen pen = new Pen(GetPrnColor(color),1);
         ValueToPoint(ValueS,IndexS,Flag,ref aPointX,ref aPointY);
         ValueToPoint(ValueE,IndexE,Flag,ref bPointX,ref bPointY);
         g.DrawLine(pen,aPointX,aPointY,bPointX,bPointY);
    }
//画线
private void  DrawLine2(Graphics g, float ValueS, float ValueE,int IndexS,int IndexE,int Flag1,int Flag2,Color TColor)
{
    float  aPointX=0.0f,aPointY=0.0f;
    float bPointX=0.0f,bPointY=0.0f;
  Pen pen = new Pen(GetPrnColor(TColor),2);
  ValueToPoint(ValueS,IndexS,Flag1,ref aPointX,ref aPointY);
  ValueToPoint(ValueE,IndexE,Flag2,ref bPointX,ref bPointY);
  g.DrawLine(pen,aPointX,aPointY,bPointX,bPointY);
}

//画圆加文字
private void  DrawEllipseX(Graphics g, float Value,float Index,int Flag,String Str,Color TColor)
    {
  int Num1,Num2;
  Font  font = new Font("宋体",10); 
  Pen   pen = new Pen(Color.Blue);
  float aPointX=0.0f,aPointY=0.0f,EllipseZ=0.0f;
  ValueToPoint(Value,Index,Flag,ref aPointX,ref aPointY);
    SizeF  size =g.MeasureString(Str,font);
    Num1 = Convert.ToInt32(size.Width);
    Num2 = Convert.ToInt32(size.Height);
  if (Num1 > Num2)
    EllipseZ = Num1;
  else
    EllipseZ = Num2;

    g.DrawEllipse(pen,aPointX-(EllipseZ)/2,aPointY-(EllipseZ)/2,aPointX+(EllipseZ)/2,aPointY+(EllipseZ)/2);

    }
public string VertStr(string s)
{
    string d = "";
    char[] Arr;
    Arr = s.ToCharArray();
    foreach (char c in Arr)
    {
        d += c.ToString() + "\r\n";
    }
    d.Replace("\r\n", "");
    return d;
}
//画字符串
private void DrawChar(Graphics g,float Value,float Index,int Flag,string Str, Color TColor,float ShiftX=0, float ShiftY=0, int ITPYE=0)
    {
  float X,Y,H,W,Height,Width;
  int DrawFlag;
  float aPointX=0.0f,aPointY=0.0f;
  Font  font = new Font("宋体",10); 
  SolidBrush  brush = new SolidBrush(TColor);
  SizeF size = g.MeasureString(Str,font);
  Rectangle  rect=new Rectangle();
  if (ITPYE==0||ITPYE==1||ITPYE==2||ITPYE==5)
    ValueToPoint(Value,Index,Flag,ref aPointX,ref aPointY);
  else
  {
    aPointX = ShiftX;
    aPointY = ShiftY;
  }
  //普通标志信息如:加V,H,R信息
  if (ITPYE==0)
  {
    g.DrawString(Str,font,brush,aPointX-size.Width/2+ShiftX,aPointY-size.Height/2+ShiftY);
  }
  //时间说明
  if (ITPYE==1)
  {
      rect.X = Convert.ToInt32(aPointX - CellWidth / 2 + size.Height);
      rect.Y = Convert.ToInt32(aPointY);
      rect.Width = Convert.ToInt32(CellWidth);
      rect.Height = Convert.ToInt32(CellHeight * 2 * 10);
     g.DrawString(Str,font,brush,rect);
  }
  //呼吸值
  if (ITPYE==3)
  {
      rect.X = Convert.ToInt32(aPointX);
      rect.Y = Convert.ToInt32(aPointY);
      rect.Width = Convert.ToInt32(CellWidth);
      rect.Height = Convert.ToInt32(Trail_height);
    g.DrawString(Str,font,brush,rect);
  //标题表格
  }
  if (ITPYE==4)
      rect.X = Convert.ToInt32(aPointX);
      rect.Y = Convert.ToInt32(aPointY);
      rect.Width = Convert.ToInt32(CellWidth);
      rect.Height=17;
      g.DrawString(Str,font,brush,rect);
  //特殊情况说明
  if (ITPYE==5)
          {
              rect.X = Convert.ToInt32(aPointX - CellWidth / 2 + size.Height);
              rect.Y = Convert.ToInt32(aPointY);
              rect.Width = Convert.ToInt32(CellWidth);
              rect.Height = Convert.ToInt32(CellHeight * 10);
                g.DrawString(Str,font,brush,rect);
          }
    }

         public bool  CompareValue(float Value1,float Index1,int Flag1,float Value2,float Index2 ,int  Flag2)
    {

         float aPointX=0.0f, aPointY=0.0f;
         float bPointX=0.0f, bPointY=0.0f;
         ValueToPoint(Value1,Index1,Flag1,ref aPointX,ref aPointY);
         ValueToPoint(Value2,Index2,Flag2,ref bPointX,ref bPointY);
         return  (aPointY-2 <= bPointY+2) && (aPointY+2 >= bPointY);
    }

        private void  DrawMX(Graphics g, string ls_zyh,string ls_bh,int Index1)
        { 

             String aStyle,C;
           //  int i;
             int h,Bak_size,MaxSD;
             int  j,n,w,icur,iqbqpl,li_return=0;
             String s;
             float iml, ixl,ntw,nfstw,nwljw,ntz;
             bool bxzqbq;
          GetASCBData(ls_zyh, ls_bh);
          MaxSD = 6;
          for (int i=0; i<= MaxSD-1;i++)
          {
              if (i >= ASCB.Rows.Count) continue;
              iml = (ASCB.Rows[i]["IML"] == DBNull.Value||ASCB.Rows[i]["IML"] =="")? 0:(float)Convert.ToDecimal(ASCB.Rows[i]["IML"]);
              ixl = (ASCB.Rows[i]["IXL"] == DBNull.Value || ASCB.Rows[i]["IXL"] == "") ? 0 : (float)Convert.ToDecimal(ASCB.Rows[i]["IXL"]);
              ntw = (ASCB.Rows[i]["NTW"] == DBNull.Value || ASCB.Rows[i]["NTW"] == "") ? 0 : (float)Convert.ToDecimal(ASCB.Rows[i]["NTW"]);
              ntz = (ASCB.Rows[i]["NTZ"] == DBNull.Value || (ASCB.Rows[i]["NTZ"] == "")) ? 0 : (float)Convert.ToDecimal(ASCB.Rows[i]["NTZ"]);
              nfstw = (ASCB.Rows[i]["NFSTW"] == DBNull.Value || ASCB.Rows[i]["NFSTW"] == "") ? 0 : (float)Convert.ToDecimal(ASCB.Rows[i]["NFSTW"]);
              nwljw = (ASCB.Rows[i]["NWLJW"] == DBNull.Value || ASCB.Rows[i]["NWLJW"] == "") ? 0 : (float)Convert.ToDecimal(ASCB.Rows[i]["NWLJW"]);
              bxzqbq=(ASCB.Rows[i]["BXZQBQ"] == DBNull.Value || ASCB.Rows[i]["BXZQBQ"] == "") ? false : bxzqbq = Convert.ToBoolean(ASCB.Rows[i]["BXZQBQ"]);
              iqbqpl = (ASCB.Rows[i]["IQBQPL"] == DBNull.Value || ASCB.Rows[i]["IQBQPL"] == "") ? 0 : Convert.ToInt32(ASCB.Rows[i]["IQBQPL"]);

              li_return = GetCurrentRow(ASCB, i);
              icur = Index1 * 6 + li_return; //当前列#
            if (TWDraw && (ntw>0 || (Convert.ToString(ASCB.Rows[i]["CTSQK"]))=="人工冬眠") && (TWStep>0))
            {    
               aStyle = "";
               C="";
              //体温
              if (Convert.ToString(ASCB.Rows[i]["CTWCLFF"]) == "口内")
                aStyle = "ptwkl";
              else
              if (Convert.ToString(ASCB.Rows[i]["CTWCLFF"]) == "直肠") 
                aStyle = "ptwzc";
              else
              if (Convert.ToString(ASCB.Rows[i]["CTWCLFF"]) == "腋下") 
                aStyle = "PTWYX";
              else
              if (Convert.ToString(ASCB.Rows[i]["CTWCLFF"]) == "药物物理降温") 
                aStyle = "ptwyw";
            //  //物理降温后体温
                  if (nwljw > 0)
                  {
                      if (nwljw == ntw)   //物理降温等于降前体温，在原体温处划圈
                          C = "x";
                      else
                      {
                          //物理降温大于体温
                          if (nwljw > ntw)
                          {
                              DrawLine(g, ntw, nwljw, icur, icur, TW, Color.Red);
                              DrawPoint(g, nwljw, icur, 0, "PXL");
                          }
                          else
                          {
                              DrawLine(g, ntw, nwljw, icur, icur, TW, Color.Red);
                              DrawPoint(g, nwljw, icur, 0, "PXL");
                          }
                      }
                  }
             
              if ((CompareValue(ntw,icur,TW,iml,icur,ML))|| (CompareValue(ntw,icur,TW,ixl,icur,XL)))
                aStyle = aStyle+"o";
              else
                aStyle = aStyle+C;
              //复试体温与测量相符，加V标志
            //  if ASCB.Rows[Index]["NFSTW"]=ASCB.Rows[Index]["NTW"] then
            //    DrawChar(ASCB.Rows[Index]["RealTW"],icur,TW,"v",clBlue,2,-6,0);
              if ((Convert.ToString(ASCB.Rows[i]["CTSQK"]) == "不升") && (ntw < 35))//体温底于35度
                  {
                  }
              else if ((Convert.ToString(ASCB.Rows[i]["CTSQK"]) == "人工冬眠") || (ntw < 35))  //体温底于35度,加向下的箭头
                  {
                      DrawLine(g,35, 35 - TWStep * 2, icur, icur, TW, Color.Blue);
                  }
              if ((ntw >= 35) && (Convert.ToString(ASCB.Rows[i]["CTSQK"]) != "人工冬眠"))
                  {
                      DrawPoint(g, ntw, icur, TW, aStyle);
                  }
          }

            if (TWDraw && (nfstw>0) && (TWStep>0))
              {
              if (nfstw>=35)
              {
                 // DrawPoint(g, (float)Convert.ToDecimal(ASCB.Rows[Index]["NFSTW"]), icur, FW, aStyle);
              }
              }

            if ((Convert.ToString(XseDt.Rows[0]["CXSEBH"]) == "") && (bxzqbq) && (iqbqpl > 0))
                    {
                        if (XLQDrawEllipse)
                        {
                            DrawEllipseX(g, (float)iqbqpl, icur, XL, "H", Color.Red);
                            DrawChar(g, (float)iqbqpl, icur, XL, "H", Color.Red);
                        }
                    }
             else
                if (MLDraw && (!bxzqbq))
                {
                    if ((ixl > 0) && (MLStep > 0) && (ixl != iml) && ((ntw == 0) || (!CompareValue(ntw, icur, TW, ixl, icur, XL))))
                    {
                        DrawPoint(g, (float)ixl, icur, XL, "PXL");
                    }
                    if (((iml > 0) && (MLStep > 0) && (ntw == 0)) || ((!CompareValue(ntw, icur, TW, (float)iml, icur, ML))))
                    {
                        DrawPoint(g, (float)iml, icur, ML, "PMB");
                    }
                }
            if (TZDraw && (ntz>0)) 
              {
                  DrawPoint(g,ntz, icur, TZ, "PXL");
              }
             //时间说明
            if (Convert.ToString(ASCB.Rows[i]["CSJSM"])!=""&&ASCB.Rows[i]["CSJSM"]!=DBNull.Value) 
              {
                  w = 0;
                  s = Convert.ToString(ASCB.Rows[i]["CSJSM"]);
                  s = s.Replace("娩术","手术");
                  C = VertStr(s);
                  DrawChar(g, (float)(42 - 0.05), (float)(icur), TW, C, Color.Black, 0, (float)(CellHeight * (42 - 40) / TWStep - 0.2), 1);  //时间说明
              }
            //写下部特殊情况文字
            if ((Convert.ToString(ASCB.Rows[i]["CTSQK"])!="")&&(Convert.ToString(ASCB.Rows[i]["CTSQK"])!="手术") && (Convert.ToString(ASCB.Rows[i]["CTSQK"])!="分娩"))
              {
                   C = VertStr(Convert.ToString(ASCB.Rows[i]["CTSQK"]));
                  DrawChar(g,35, (float)(icur), TW, C, Color.Black, 0, (float)(CellHeight * (35 - 34) / TWStep - 0.2), 5); //特殊情况
              }
          }
        }
     

        private bool CanDrawLine(float V1, float V2)
        {
           if (V1!=V2)
               return true;  //不相等，必画连线
           else
             return  EqualLine;
        }
//检查是否连线
        public bool DontLine(int Index, int i)
        {
            String s;
            bool Result;
            int x;
            string[] DontLineStrings;
            Result = false;
            //s := ASCB.Rows[index],I,'CTSQK') +'|'+ ASCB.Rows[index],I,'CSJSM');
            //DontLineStrings := TStringList.create;
            //  try
            //   DontLineStrings.Text := Trim(StringReplace(DontLineS,';',#13));
            //   for x := 0 to DontLineStrings.Count - 1 do
            //    if Pos(DontLineStrings[x],s)>0 then
            //    begin
            //      Result := True;
            //      Exit;
            //    end;
            //  finally
            //    DontLineStrings.Free;
            //  end;
            //end;
            return Result;
        }
 private Int32 GetCurrentRow(DataTable dt,Int32 rownumber)
        {
            Int32 i;
            i = Convert.ToInt32(dt.Rows[rownumber]["IJLLB"]);
            return i - 1;

        }

private void  Draw(Graphics g)
{
    int icur, IHXHeight, li_return = 0;
    DateTime RQ;
    int iHX;
    string HXQChar = "R",ls_bh,ls_zyhm;
    float TWstart, TWend, FWStart, FWend, MLstart, MLend, XLstart, XLend, HXstart, HXend, TZstart, TZend, XLQstart, XLQend;
    int TWindex, MLindex, HXindex, TZindex, XLQindex, XLindex;
    float[] DC_XL_X, DC_XL_Y, DC_ML_X, DC_ML_Y;
    Font font = new Font("宋体",10);
    Brush blackbrush = new SolidBrush(Color.Black);
      //RQ := DrawSCB.PageIndex[DrawSCB.CurPage];
      //画线起始值(行)，起始列号
      TWstart = 0;  TWend = 0;  TWindex  = -1;
      MLstart = 0;  MLend = 0;  MLindex  = -1;
      XLstart = 0;  XLend = 0;  XLindex  = -1;
      HXstart = 0;  HXend = 0;  HXindex  = -1;
      TZstart = 0;  TZend = 0;  TZindex  = -1;
      XLQstart= 0;  XLQend= 0;  XLQindex = -1;
      FWStart = 0; FWend = 0;
      iHX = 0;
      for (int index = 0; index <= 6; index++) //7天
      {
          if (index >=DrawSCB.Rows.Count ) break;
          if ((DrawSCB.Rows[index]["CBH"] == DBNull.Value) || (DrawSCB.Rows[index]["CBH"] == "")) continue;
          ls_bh = DrawSCB.Rows[index]["CBH"].ToString();
          ls_zyhm = DrawSCB.Rows[index]["CZYH"].ToString();
          GetASCBData(ls_zyhm, ls_bh);
          for (int i = 0; i <= 5; i++)
          {
              if (i >= ASCB.Rows.Count) continue;
              li_return = GetCurrentRow(ASCB, i);
              icur = index * 6 + li_return; //当前列#
              if (XseDt.Rows[0]["CXSEBH"] != "")
              {
                  //体重
                  if (ASCB.Rows[i]["NTZ"]!=DBNull.Value&&ASCB.Rows[i]["NTZ"]!="")
                  TZend = (float)Convert.ToDecimal(ASCB.Rows[i]["NTZ"]);
                  if (TZend != 0)
                  {
                      if ((TZstart != 0) && (TZindex != -1) && CanDrawLine(TZstart, TZend))
                          DrawLine(g, TZstart, TZend, TZindex, icur, TZ, GetPrnColor(TZColor));
                      TZindex = icur;
                  }
              }
              //体温
              if(ASCB.Rows[i]["NTW"]!=DBNull.Value&&ASCB.Rows[i]["NTW"]!="")
              TWend = (float)Convert.ToDecimal(ASCB.Rows[i]["NTW"]);
              if (ASCB.Rows[i]["NFSTW"]!=DBNull.Value&&ASCB.Rows[i]["NFSTW"]!="") FWend = (float)Convert.ToDecimal(ASCB.Rows[i]["NFSTW"]);
              if ((TWend != 0) && (TWStep != 0))
              {
                  if ((FWStart != 0) && (TWindex != -1))
                  {
                      if (CanDrawLine(FWStart, TWend))
                      {
                          if (index + 1 >= PrnStartDay)
                              DrawLine2(g, FWStart, TWend, TWindex, icur, FW, TW, GetPrnColor(TWColor));
                      }
                  }
                  else
                  {
                      // if (TWstart<>0) and (TWindex<>-1) and CanDrawLine(TWstart,TWend) then  //相临体温相等时不划线
                      if ((TWstart != 0) && (TWindex != -1))
                      {
                          if (index + 1 >= PrnStartDay)
                              DrawLine(g, TWstart, TWend, TWindex, icur, TW, GetPrnColor(TWColor));
                      }
                  }
                  TWindex = icur;
                  if ((FWend != 0) && (TWindex != -1))
                  {
                      // if (FWend<>0) and (Twindex<>-1) and canDrawLine(FWend,TWend) then
                      if (index + 1 >= PrnStartDay)
                          DrawLine2(g, TWend, FWend, TWindex, icur, TW, FW, GetPrnColor(TWColor));
                  }
                  TWindex = icur;
                  TWstart = TWend;
                  FWStart = FWend;
              }

              if (((float)Convert.ToDecimal(ASCB.Rows[i]["NTW"]) < 35) && (ASCB.Rows[i]["CTSQK"] == "不升"))
              {
                  DrawChar(g, 35 - TWStep, icur, TW, "不\r\n10升", Color.Blue);
              }
              if ((TWstart != 0) && DontLine(index, i))
                  TWstart = 0;  //检查是否连线
              //脉率
              if (ASCB.Rows[i]["IML"]!=DBNull.Value&&ASCB.Rows[i]["IML"]!="")
              MLend = (float)Convert.ToDecimal(ASCB.Rows[i]["IML"]);
              //心率
              if (ASCB.Rows[i]["IXL"]!=DBNull.Value&&ASCB.Rows[i]["IXL"]!="")
              XLend = (float)Convert.ToDecimal(ASCB.Rows[i]["IXL"]);
              //心率(起捕器)
              if (XseDt.Rows[0]["CXSEBH"] == "")
              {
                  if (ASCB.Rows[i]["IQBQPL"]!=DBNull.Value&&ASCB.Rows[i]["IQBQPL"]!="")
                  XLQend = (float)Convert.ToDecimal(ASCB.Rows[i]["IQBQPL"]);
              }
              if ((XLQend != 0) &&                      //使用了启搏器
                (((MLend == 0) && (XLend == 0)) ||         //  未录入心率或脉率
                ((XLQend == MLend) && (XLend == 0)) ||       //  或录入脉率与启捕器频率相等
                ((XLQend == XLend) && (MLend == 0)) ||      //  或录入心率与启捕器频率相等
                ((XLQend == MLend) && (XLQend == XLend))))
              {
                  if ((XLQstart != 0) && (XLQindex != -1))
                  {
                      if (index + 1 >= PrnStartDay)
                      {
                          DrawLine(g, XLQstart, XLQend, XLQindex, icur, XL, GetPrnColor(MBColor));
                      }
                  }
                      XLQindex = icur;
                      XLQstart = XLQend;
                      if (MLend != 0)
                      {
                          MLindex = icur;
                          MLstart = MLend;
                      }
                      if (XLend != 0)
                      {
                          XLindex = icur;
                          XLstart = XLend;
                      };
                  }
                  else
                  {
                      //脉率
                      if ((MLend != 0) && (MLStep != 0))
                      {
                          //if (MLstart<>0) and (MLindex<>-1) and CanDrawLine(MLstart,MLend) then
                          if ((MLstart != 0) && (MLindex != -1))   //相临相等时不划线
                              if (index + 1 >= PrnStartDay)
                                  DrawLine(g, MLstart, MLend, MLindex, icur, ML, GetPrnColor(MBColor));
                          MLindex = icur;
                          MLstart = MLend;
                          if (XLend == 0)
                              XLstart = 0;
                      }
                      //心率
                      if ((XLend != 0) && (MLStep != 0))
                      {
                          // if (XLstart<>0) and (XLindex<>-1) and CanDrawLine(XLstart,XLend) then
                          if ((XLstart != 0) && (XLindex != -1)) //相临相等时不划线
                              if ((index + 1 >= PrnStartDay))
                                  DrawLine(g, XLstart, XLend, XLindex, icur, XL, GetPrnColor(MBColor));
                          XLindex = icur;
                          XLstart = XLend;
                          if (MLend == 0) MLstart = 0;
                      }
                      //
                      if (XLQend != 0)
                      {
                          XLQindex = icur;
                          XLQend = 0;
                      }
                  }
                  //呼吸
                  if ((ASCB.Rows[i]["IHX"] != DBNull.Value)&&(ASCB.Rows[i]["IHX"] !=""))
                      HXend = (float)Convert.ToDecimal(ASCB.Rows[i]["IHX"]);
                  IHXHeight = 0;
                  if (HXend != 0)
                  {
                      if ((icur % 2) == 0)
                          IHXHeight = 0;
                      else
                          IHXHeight = 10;
                      if (ASCB.Rows[i]["BHXQ"] == DBNull.Value || ASCB.Rows[i]["BHXQ"]=="")
                          g.DrawString(HXend.ToString(), font, blackbrush, TopX + ShiftX + CellWidth * icur, height + IHXHeight);
                      else
                      {
                      if ((bool)ASCB.Rows[i]["BHXQ"])
                          g.DrawString(HXQChar, font, blackbrush, (float)(TopX + ShiftX + CellWidth * icur), (float)(height + IHXHeight));
                      else
                          g.DrawString(HXend.ToString(), font, blackbrush, TopX + ShiftX + CellWidth * icur, height + IHXHeight);
                      }
                  }

                  if ((ASCB.Rows[i]["CSJSM"].ToString().IndexOf("请假") > 0) || (ASCB.Rows[i]["CSJSM"].ToString().IndexOf("不在") > 0))
                  {
                      TWstart = 0;
                      MLstart = 0;
                      XLstart = 0;
                      HXstart = 0;
                      TZstart = 0;
                      XLQstart = 0;
                      FWStart = 0;
                  }

                  //心率短绌
                  if ((XLend > 0) && (MLend > 0) && (XLend > MLend))
                  {
                      //ValueToPoint(XLend, icur, XL, ref DC_XL_X[((DC_XL_X).Length + 1)], ref DC_XL_Y[((DC_XL_Y).Length + 1)]);
                      //ValueToPoint(MLend, icur, ML, ref DC_ML_X[((DC_ML_Y).Length + 1)], ref DC_ML_Y[((DC_ML_Y).Length + 1)]);
                  }
                  if ((MLstart != 0) && DontLine(index, i)) MLstart = 0;  //检查是否连线
                  if ((XLstart != 0) && DontLine(index, i)) XLstart = 0;  //检查是否连线
                  if ((XLQstart != 0) && DontLine(index, i)) XLQstart = 0;  //检查是否连线
                  //绘制心率短绌(XLstart=0)
                  if (((XLend > 0) && (XLend == MLend)) || ((XLend == 0) && (MLend != 0)) || ((XLend != 0) && (MLend == 0)) || (DontLine(index, i)))
                  {
                      //if (index+1>=PrnStartDay)  
                      //    g.DrawRangeArray(DC_XL_X,DC_XL_Y,DC_ML_X,DC_ML_Y,clred);//绘制心率短绌
                      //setlength(DC_XL_X,0);
                      //setlength(DC_XL_Y,0);
                      //setlength(DC_ML_X,0);
                      //setlength(DC_ML_Y,0);
                  }
          }
      }
          ////  //绘制心率短绌
          ////  if Length(DC_XL_X)>0 then
          ////  begin
          ////    image.DrawRangeArray(DC_XL_X,DC_XL_Y,DC_ML_X,DC_ML_Y,clred);//绘制心率短绌
          ////    setlength(DC_XL_X,0);
          ////    setlength(DC_XL_Y,0);
          ////    setlength(DC_ML_X,0);
          ////    setlength(DC_ML_Y,0);
          ////  end;
      for(int index=0;index<7;index++)  //7天
      {
         if (index >=DrawSCB.Rows.Count ) break;
          if (DrawSCB.Rows[index]["CBH"] == DBNull.Value||DrawSCB.Rows[index]["CBH"] =="") continue;
          ls_bh = DrawSCB.Rows[index]["CBH"].ToString();
          ls_zyhm = DrawSCB.Rows[index]["CZYH"].ToString();
          
        //绘点
          if (index + 1 >= PrnStartDay)
              DrawMX(g, ls_zyhm, ls_bh, index);
      }
}

private void ShowHeader(Graphics g)
{
    const int SSJLTS = 14; //手术记录天数
    //   // SSJL: array[0..9] of string=('','II','III','IV','V','VI','VII','VIII','IX','X');
    //string[] SSJL = new string[] {"","II","III","IV","V","VI","VII","VIII","IX","X" };
    int m,n,ts, lindex;
    DateTime ltmp, lssdate;
    int[] lssrq;
    int lss, lts;
    int Columns;
    string CSQL, Str;
    string[] SSJL = new string[10];
    DateTime RQ;
    RectangleF rect = new RectangleF();
    SSJL[0] = "";
    SSJL[1] = "II";
    SSJL[2] = "III";
    SSJL[3] = "IV";
    SSJL[4] = "V";
    SSJL[5] = "VI";
    SSJL[6] = "VII";
    SSJL[7] = "VIII";
    SSJL[8] = "IX";
    SSJL[9] = "X";
    Columns = 7;
    Font font = new Font("宋体", 9);
    Font font_7 = new Font("宋体", 7);
    Brush blackbrush = new SolidBrush(Color.Black);
    Brush redbrush = new SolidBrush(Color.Red);
    FontFamily fontFamily = new FontFamily("宋体");
    System.Drawing.Font drawFont = new System.Drawing.Font(fontFamily, 12, GraphicsUnit.Pixel);
    System.Drawing.Font drawFont_1 = new System.Drawing.Font(fontFamily, 10, GraphicsUnit.Pixel);
    StringFormat Format = new StringFormat();
    Format.Alignment = StringAlignment.Center;
    //graphics.DrawString("这里就是要画的文字  " + DateTime.Now.ToString() , drawFont, drawBrush, drawRect, Format);
    if (DrawSCB.Rows.Count <= 0) return;
    g.DrawString(DrawSCB.Rows[0]["CXM"].ToString(), font, blackbrush, (float)(TopX + 35), (float)(TopY - 18)); //姓名
    g.DrawString(DrawSCB.Rows[0]["NNL"].ToString(), font, blackbrush, (float)(TopX + 156), (float)(TopY - 18));//年龄
    g.DrawString(DrawSCB.Rows[0]["CXB"].ToString(), font, blackbrush, (float)(TopX + 232), (float)(TopY - 18));//性别
    g.DrawString(DrawSCB.Rows[0]["CZYKSMC"].ToString(), font, blackbrush, (float)(TopX + 291), (float)(TopY - 18));//科室
    g.DrawString(DrawSCB.Rows[0]["CCHMC"].ToString(), font, blackbrush, (float)(TopX + 390), (float)(TopY - 18));//床位
    g.DrawString(Convert.ToDateTime(DrawSCB.Rows[1]["DRYSJ"]).ToString("yyyy.MM.dd"), font, blackbrush, (float)(TopX + 500), (float)(TopY - 18));//入院时间
    g.DrawString(DrawSCB.Rows[0]["CZYH"].ToString(), font, blackbrush, (float)(TopX + 660), (float)(TopY - 18));//住院号
    if (li_currentpage==1)
       RQ = Convert.ToDateTime(DrawSCB.Rows[0]["DRQ"]);
    else
        RQ = Convert.ToDateTime(DrawSCB.Rows[li_currentpage*7]["DRQ"]);
    //时间
    for (int i = 0; i <= 6; i++)
    {
        for (int j = 0; j <= 5; j++)
        {
            Str = HourDt.Rows[j]["IMC"].ToString();
            rect.X = (float)(ShiftX + TopX + CellWidth * j + CellWidth * i * 6);
            rect.Y = (float)(TopY + Header_CellHeight * 4 + 4);
            rect.Width = (float)(CellWidth);
            rect.Height = (float)(Title_height);
            if (HourDt.Rows[j]["CBZ"].ToString() == "夜")
                g.DrawString(Str, drawFont_1, blackbrush, rect, Format);
            else
                g.DrawString(Str, drawFont_1, blackbrush, rect, Format);
        }
    }
        if (DrawSCB.Rows.Count == 0) return;
          lindex =li_currentpage - 1;
        lss = 0; //手术次数
        lts = 0; //当前术后天数
        //   setlength(LSSRQ,0);
          if (XseDt.Rows[0]["CXSEBH"].ToString()=="" ||(lindex>-1))
          {
            n= 0;
            if (n==-1)  n = 0;
            for (int i= n ;i<= lindex;i++) 
            {
              //if ASCB.ItemByName(I,0,'DSSRQ')>0 then
              //  {
              //  setlength(lssrq,Length(lssrq)+1);  //保存每一次手术日期
              //  lssrq[Length(lssrq)-1] := trunc(ASCB.ItemByName(I,0,'DSSRQ'));
              //  lts := 1;
              //  }
              //  else
              //if Length(lssrq)>0 then
              //  Inc(lts);
            }
          }

          for (int i = 1; i <= Columns; i++)
          {
              //    lindex := DrawSCB.DataIndex[i-1];
              //    //日期
              rect.X = ShiftX + TopX + CellWidth * (i - 1) * 6;
              rect.Y = TopY + 5;
              rect.Width = CellWidth * 6;
              rect.Height = 17;
              if (i == 1)
                  g.DrawString(RQ.ToString("yyyy.MM.dd"), drawFont, blackbrush, rect, Format);
              else
                  if (RQ.Date.AddDays(i - 1).Day.ToString() == "01")
                  {
                      if (RQ.Date.AddMonths(i - 1).Month.ToString() == "01")
                          g.DrawString(RQ.Date.AddMonths(i - 1).ToString("yyyy.MM.dd"), drawFont, blackbrush, rect, Format);
                      else
                          g.DrawString(RQ.Date.AddDays(i - 1).ToString("MM.dd"), drawFont, blackbrush, rect, Format);
                  }
                  else
                      g.DrawString(RQ.Date.AddDays(i - 1).Day.ToString(), drawFont, blackbrush, rect, Format);
              //住院天数
              ts = (RQ - Convert.ToDateTime(DrawSCB.Rows[1]["DRYSJ"])).Days + i - 1;

              if (ts >= 0)
              {
                  rect.X = ShiftX + TopX + CellWidth * (i - 1) * 6;
                  rect.Y = TopY + Header_CellHeight + 5;
                  rect.Width = CellWidth * 6;
                  rect.Height = 20;
                  g.DrawString((ts + 1).ToString(), drawFont, blackbrush, rect, Format);
              }
              //      //术后天数
              if (XseDt.Rows[0]["CXSEBH"] == "")
              {
              //    //      if (lindex>-1) and (lindex<ASCB.ItemCount) and (ASCB.ItemByName(lindex,0,'DSSRQ')>0) then
              //    //      begin
              //    //        setlength(lssrq,Length(lssrq)+1);
              //    //        lssrq[Length(lssrq)-1] := trunc(ASCB.ItemByName(lindex,0,'DSSRQ'));
              //    //      end;
              //    //      image.DrawText(Trunc(ShiftX+TopX+CellWidth*(I-1))*6,Trunc(TopY+Header_CellHeight*2+5),'', '宋体',10, clBlack);
              //    //      Str := '';
              //    //      if Length(lssrq)>0 then
              //    //      begin
              //    //        lss := 0;
              //    //        for j:= 0 to Length(lssrq)-1 do
              //    //        begin
              //    //          lts := trunc(RQ)+I-1 - lssrq[j];
              //    //          Inc(lss);
              //    //          if (lss>0) and (lts<=SSJLTS) then
              //    //           str :=  IntToStr(lts);
              //    //          if (lss>1) and (str<>'') then
              //    //          begin
              //    //           if str='0' then
              //    //            str :=  SSJL[lss-1]+'-'+IntToStr(lts)
              //    //          end;
              //    //        end;
              //    //     Image.DrawRText(Trunc(ShiftX+TopX+CellWidth*(I-1)*6),Trunc(TopY+Header_CellHeight*2+3),Trunc(CellWidth*6),20,Str,'',-1,-1,-1,taCenter);
              }
          }
    //  lss := trunc(DrawSCB.PageIndex[DrawSCB.CurPage]-ASCB.ItemByName(0,0,'DRQ'))+1;
    //  //页码
    //  image.drawtext(360,1050,IntToStr((lss+7) div 7),'宋体',10,clred) ;
}



        private void  ShowFooter(Graphics g)
        {
      int lindex,m,n;
      string  Str="",s;
      float    Value;
      string[] LstYLL;
      string ls_bh, ls_zyhm;
      RectangleF rect = new RectangleF();
      Font font = new Font("宋体", 9);
      Font font_7 = new Font("宋体", 7);
      Brush blackbrush = new SolidBrush(Color.Black);
      Brush redbrush = new SolidBrush(Color.Red);
      Brush bluebrush = new SolidBrush(Color.Blue);
      FontFamily fontFamily = new FontFamily("宋体");
      System.Drawing.Font drawFont = new System.Drawing.Font(fontFamily, 12, GraphicsUnit.Pixel);
      System.Drawing.Font drawFont_1 = new System.Drawing.Font(fontFamily, 10, GraphicsUnit.Pixel);
      StringFormat Format = new StringFormat();
      Format.Alignment = StringAlignment.Center;
     if (Convert.ToString(XseDt.Rows[0]["CXSEBH"]) != "") return;
      for(int i=0;i<=6 ;i++ )
      {
          if (i >= DrawSCB.Rows.Count) return;
          if (DrawSCB.Rows[i]["CBH"] == DBNull.Value) continue;
          ls_bh = DrawSCB.Rows[i]["CBH"].ToString();
          ls_zyhm = DrawSCB.Rows[i]["CZYH"].ToString();
          GetASCBData(ls_zyhm, ls_bh);


          if (DrawSCB.Rows[i]["CXYDW"].ToString().ToUpper().IndexOf("KPA") > 0)
              Value = 7.502f;
          else if (DrawSCB.Rows[i]["CXYDW"].ToString().ToUpper().IndexOf("MMHG") > 0)
              Value = 1;
          else
              Value = 1;
         if ((DrawSCB.Rows[i]["NSSY"] != DBNull.Value)&&(DrawSCB.Rows[i]["NSSY"] !=""))
         {
            //try
            //    {
                    //Str = DrawSCB.Rows[i]["NSSY"].ToString();
                     Str = GetSCBNumStr((float)Convert.ToDecimal(DrawSCB.Rows[i]["NSSY"]), "XYdict", Value);
         //       }
         //catch   (Exception e)
         //     {
         //         MessageBox.Show(e.Message);
         //     }
         }
      else
        Str = "";
    Str = Str + "/";
    if ((DrawSCB.Rows[i]["NSZY"] != DBNull.Value)&&DrawSCB.Rows[i]["NSZY"] !="")
        Str = Str + GetSCBNumStr((float)Convert.ToDecimal(DrawSCB.Rows[i]["NSZY"]), "XYdict", Value);
        if(Str=="/")  Str="";
        if(Str.IndexOf("外出")>0) Str="外出";
        if (Str.IndexOf("无法测量") > 0) Str = "无法测量";
        if (Str.IndexOf("刀伤") > 0) Str = "刀伤";
          rect.X=ShiftX+TopX+CellWidth*i*6;
          rect.Y = Header_CellHeight * 3 + Title_height + TopY + CellHeight * 8 * 5 + Trail_height + 2 + CellHeight + Header_CellHeight;
          rect.Width = CellWidth * 3;
          rect.Height = 20;
          g.DrawString(Str, drawFont, blackbrush, rect, Format);
//    //血压2
     Str = "";
     if ((DrawSCB.Rows[i]["NSSY2"] != DBNull.Value)&&(DrawSCB.Rows[i]["NSSY2"] !=""))
         s = GetSCBNumStr((float)Convert.ToDecimal(DrawSCB.Rows[i]["NSZY2"]), "XYdict", Value);
     else
         s = "";
     s=s+"/";
     if ((DrawSCB.Rows[i]["NSZY2"] != DBNull.Value)&&DrawSCB.Rows[i]["NSZY2"] !="")
         s = s + GetSCBNumStr((float)Convert.ToDecimal(DrawSCB.Rows[i]["NSZY2"]), "XYDict", Value);
    if(s!="/")  Str=s;
    if(Str.IndexOf("外出")>0) Str="外出";
    if(Str.IndexOf("拒测")>0) Str="拒测";
    if(Str.IndexOf("无法测量")>0) Str="无法测量";
    if(Str.IndexOf("刀伤")>0) Str="刀伤";
          rect.X=ShiftX+TopX+CellWidth*i*6;
          rect.Y = Header_CellHeight * 3 + Title_height + TopY + CellHeight * 8 * 5 + Trail_height + 2 + CellHeight + Header_CellHeight;
          rect.Width = CellWidth*6+CellWidth*3;
          rect.Height = 20;
          g.DrawString(Str, drawFont, blackbrush, rect, Format);
//    //入量

      if (IsNumeric(DrawSCB.Rows[i]["IYRL"].ToString())) 
        Value =(float)Convert.ToDecimal(DrawSCB.Rows[i]["IYRL"]);
      else
        Value = 0;
      if (IsNumeric(DrawSCB.Rows[i]["ISRL"].ToString())) 
        Value = Value+ (float)Convert.ToDecimal(DrawSCB.Rows[i]["ISRL"]);
      else
        Value = Value+0;
      if (IsNumeric(DrawSCB.Rows[i]["IYRL"].ToString()) && (IsNumeric(DrawSCB.Rows[i]["ISRL"].ToString())))
      {
          rect.X = ShiftX + TopX + CellWidth * i * 6;
          rect.Y = Header_CellHeight * 4 + Title_height + TopY + CellHeight * 8 * 5 + CellHeight + Trail_height + 2 + Header_CellHeight;
          rect.Width = CellWidth * 6;
          rect.Height = 20;
          g.DrawString(Value.ToString(), drawFont, blackbrush, rect, Format);
      }
   


      if (IsNumeric(DrawSCB.Rows[i]["IXBL"].ToString()))
        Value = (float)Convert.ToDecimal(DrawSCB.Rows[i]["IXBL"]);
      else
        Value = 0;
      if (IsNumeric(DrawSCB.Rows[i]["NCLQT"].ToString()))
        Value = (float)Convert.ToDecimal(DrawSCB.Rows[i]["NCLQT"]);
      else
        Value = Value+0;
      if (IsNumeric(DrawSCB.Rows[i]["CDBL"].ToString()))
        Value = Value+(float)Convert.ToDecimal(DrawSCB.Rows[i]["CDBL"]);
      else
        Value = Value+0;
      if (IsNumeric(DrawSCB.Rows[i]["NYLL"].ToString()))
        Value = Value+(float)Convert.ToDecimal(DrawSCB.Rows[i]["NYLL"]);
      else
        Value = Value+0;
      if   (IsNumeric(DrawSCB.Rows[i]["NCLQT"].ToString()) ||  IsNumeric(DrawSCB.Rows[i]["CDBL"].ToString())|| IsNumeric(DrawSCB.Rows[i]["NYLL"].ToString()))
      {
          rect.X = ShiftX+TopX+CellWidth*i*6;
          rect.Y = Header_CellHeight * 4 + Title_height + TopY + CellHeight + CellHeight * 8 * 5 + Trail_height + 2 + Header_CellHeight * 2;
          rect.Width = CellWidth*6;
          rect.Height = 20;
          g.DrawString(Value.ToString(), drawFont, blackbrush, rect, Format);
      }

    //大便次
    Str = DrawSCB.Rows[i]["CDBCS"].ToString();
    //n = Str.IndexOf("^");
    //if (n>0)
    //{
    // Str = Str.Substring(1, n + 1) + "</SUP>" + Str.Substring(2, Str.Length);
    //}
    //else
    //{

    //    Str = @"<P align=""center"">" + Str.Replace("^", "<SUP>") + "</P>";
    //}
    if(Str!="")
    {
        rect.X = ShiftX + TopX + CellWidth * i * 6 ;
        rect.Y = Header_CellHeight*4+Title_height+TopY+CellHeight+CellHeight*8*5+Trail_height+2+Header_CellHeight*3;
        rect.Width = CellWidth * 6;
        rect.Height = 20;
        g.DrawString(Str, drawFont, blackbrush, rect, Format);
    }
          
  //  Image.DrawHTML(Trunc(ShiftX+TopX+CellWidth*I*6+34),Trunc(Header_CellHeight*4+Title_height+TopY+CellHeight+CellHeight*8*5+Trail_height+2)+Trunc(Header_CellHeight)*3,Str,'',-1,-1,-1);
//    //体重
      if (IsNumeric(DrawSCB.Rows[i]["NTZ"].ToString()))
      {
          Value = (float)Convert.ToDecimal(DrawSCB.Rows[i]["NTZ"].ToString());
          rect.X = ShiftX + TopX + CellWidth * i * 6;
          rect.Y = Header_CellHeight * 4 + Title_height + TopY + CellHeight + CellHeight * 8 * 5 + Trail_height + 2 + Header_CellHeight * 5;
          rect.Width = CellWidth * 6;
          rect.Height = 20;
          g.DrawString(Value.ToString(), drawFont, blackbrush, rect, Format);
      }
        
  
    //身高
    Value = 1;
    Str = "";
          if (IsNumeric(DrawSCB.Rows[i]["ISG"].ToString())) 
          {
              Str = GetSCBNumStr((float)Convert.ToDecimal(DrawSCB.Rows[i]["ISG"]), "SGDict", Value);
          }
      if (IsNumeric(DrawSCB.Rows[i]["ISG"].ToString()))
      {
          rect.X = ShiftX + TopX + CellWidth * i * 6;
          rect.Y = Header_CellHeight*4+Title_height+TopY+CellHeight+CellHeight*8*5+Trail_height+2+Header_CellHeight*4;
          rect.Width = CellWidth * 6;
          rect.Height = 20;
          g.DrawString(Str, drawFont, blackbrush, rect, Format);
      }
      Value = 1;
      if (IsNumeric(DrawSCB.Rows[i]["IXBL"].ToString()))
      {
          Str = GetSCBNumStr((float)Convert.ToDecimal(DrawSCB.Rows[i]["IXBL"]), "XBDict", Value);
      }
      if (IsNumeric(DrawSCB.Rows[i]["IXBL"].ToString()))
      {
          rect.X = ShiftX + TopX + CellWidth * i * 6;
          rect.Y = Header_CellHeight * 4 + Title_height + TopY + CellHeight + CellHeight * 8 * 5 + Trail_height + 2 + Header_CellHeight * 4;
          rect.Width = CellWidth * 6;
          rect.Height = 20;
          g.DrawString(Str, drawFont, blackbrush, rect, Format);
      }
//  if VarIsNumeric(ASCB.ItemByName(lindex,0,'IXBL')) then
//   Image.DrawRText(Trunc(ShiftX+TopX+CellWidth*I*6),Trunc(Header_CellHeight*4+Title_height+TopY+CellHeight+CellHeight*8*5+Trail_height+2)+Trunc(Header_CellHeight)*6,Trunc(CellWidth*6),20,floattostr(ASCB.ItemByName(lindex,0,'IXBL')),'',-1,-1,-1,taCenter)

//    //其它
              Str =DrawSCB.Rows[i]["NQT"].ToString();
          rect.X = ShiftX + TopX + CellWidth * i * 6;
          rect.Y = Header_CellHeight * 4 + Title_height + TopY + CellHeight + CellHeight * 8 * 5 + Trail_height + 2 + Header_CellHeight * 6;
          rect.Width = CellWidth * 6;
          rect.Height = 20;
    if (Str.IndexOf("+")> 0)
         g.DrawString(Str, drawFont, redbrush, rect, Format);
     //Image.DrawRText(Trunc(ShiftX+TopX+CellWidth*I*6),Trunc(Header_CellHeight*4+Title_height+TopY+CellHeight+CellHeight*8*5+Trail_height+2)+Trunc(Header_CellHeight)*6,Trunc(CellWidth*6),20,ASCB.ItemByName(lindex,0,'NQT'),'',-1,clred,-1,taCenter)
    else
         g.DrawString(Str, drawFont, bluebrush, rect, Format);
      //Image.DrawRText(Trunc(ShiftX+TopX+CellWidth*I*6),Trunc(Header_CellHeight*4+Title_height+TopY+CellHeight+CellHeight*8*5+Trail_height+2)+Trunc(Header_CellHeight)*6,Trunc(CellWidth*6),20,ASCB.ItemByName(lindex,0,'NQT'),'',-1,clblue,-1,taCenter)*)
      }
    }
        private void ShowSCB(Graphics g)
        {
          DateTime SBegin;
          GetData("1722532");
      //    GetDataFromXML();
           if (IHT < IHT1)
            {
                MessageBox.Show("绘图值不能小于第二次绘图值，请修改!");
                return;
            }
          SBegin = Convert.ToDateTime(DrawSCB.Rows[0]["DRYSJ"]);
           //if Trunc(image.StartTime)<=sBegin then image.StartTime := sBegin+1;
         ShowHeader(g);
         Draw(g);
         ShowFooter(g);
        }


protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            DrawGrid(e.Graphics);
            if (drawb)
                ShowSCB(e.Graphics);
        }
public bool DrawGrid(Graphics g)

        {

 
          int I,N;
          string s;
          float Header_TopY;          //上表格起始y坐标
          int Header_CellHeight;       //上表格单元格高度
          int Footer_TopY;          //下表格起始y坐标 GridWidth*3+Title_height+TopY+CellHeight*8*5+Trail_height
          float Footer_CellHeight;    //下表格单元格高度
          int TopX=35;              //画图起始0点座标
          int TopY=200;         //画图起始0点座标
           int ShiftX =100;       //左边空距
          int IMageright=0;     //右边空距
          int CellWidth=14;     //每格单元(最小单元格)宽度
          int CellHeight=14;    //每格单元(最小单元格)宽度高度
          int Width=688;         //宽度
          int height=869-30;        //高度
          int Title_height=20;   //Title高度（时段）
          int Trail_height=24;  //trail高度(呼吸)
          int GridHeight=20;   //上表格高度
          //int SCPointY= 10;
          //int SCPointx= 10;
          Pen  pen =new Pen(Color.Black,2);
          Pen pen_1 = new Pen(Color.Black, 1);
          Pen penred = new Pen(Color.Red, 2);
          Font t_Font = new Font("宋体", 10F);
          g.Clear(Color.White);
          //外框
          DrawGrid(g, TopX, TopY, Width, height, 1, 1, pen);
          DrawGrid(g, ShiftX + TopX, TopY, Width - ShiftX - IMageright, GridHeight * 4,4,7,pen_1);  //画上表头
          DrawGrid(g, ShiftX + TopX, TopY, Width - ShiftX - IMageright, GridHeight * 4, 4, 1, pen); //上表头横线加粗
          DrawGrid(g, TopX, TopY, TopY, GridHeight * 3, 3, 0, pen_1);  //上表头左侧横线
         //// //画上午和下午线
          DrawGrid(g, ShiftX + TopX, GridHeight * 3 + TopY, Width - ShiftX - IMageright, Title_height, 1, 7*2,pen_1);
         //////画时间线
          DrawGrid(g, ShiftX + TopX, GridHeight * 4 + TopY, Width - ShiftX - IMageright, Title_height, 1, 7 * 6, pen_1);
          DrawGrid(g, ShiftX + TopX, GridHeight * 4 + TopY, Width - ShiftX - IMageright, Title_height, 1, 7 * 1, pen);  //时间线日竖线加粗
          g.DrawLine(pen, ShiftX + TopX, GridHeight * 4 + Title_height + TopY, ShiftX + TopX, GridHeight * 4 + Title_height + TopY + CellHeight);//42度旁一小条加粗竖线，没有意义
          for (int i = 1; i <= 42; i++)
          {
              if (i == 6 || i == 12 || i == 18 | i == 24 || i == 30 | i == 36)
                  g.DrawLine(penred, ShiftX + TopX + i * CellWidth, GridHeight * 4 + Title_height + TopY, ShiftX + TopX + i * CellWidth, GridHeight * 4 + Title_height + TopY + CellHeight);  //主体最上一格6根红色竖线
              else
                  g.DrawLine(pen_1, ShiftX + TopX + i * CellWidth, GridHeight * 4 + Title_height + TopY, ShiftX + TopX + i * CellWidth, GridHeight * 4 + Title_height + TopY + CellHeight);  //主体最上一格黑色竖线
          }

          DrawGrid(g, ShiftX + TopX, GridHeight * 4 + Title_height + TopY + CellHeight, Width - ShiftX - IMageright, CellHeight * 8 * 5, 8 * 5, 7 * 6, pen_1); //画主体格子
          for (int i = 1; i <= 6; i++)
          {

              g.DrawLine(penred, ShiftX + TopX + CellWidth * i * 6, GridHeight * 4 + Title_height + TopY + CellHeight, ShiftX + TopX + CellWidth * i * 6, GridHeight * 4 + Title_height + TopY + CellHeight + CellHeight * 8 * 5);//主体最6根红色竖线
          }

          for (int i = 1; i <= 7; i++)
          {
              if (i == 5)
                  g.DrawLine(penred, ShiftX + TopX, GridHeight * 4 + Title_height + TopY + CellHeight * i * 5 + CellHeight , Width - IMageright + TopX , GridHeight * 4 + Title_height + TopY + CellHeight + CellHeight * i * 5 );//主体一根红色横线
              else
                  g.DrawLine(pen, ShiftX + TopX, GridHeight * 4 + Title_height + TopY + CellHeight * i * 5 + CellHeight , Width - IMageright + TopX , GridHeight * 4 + Title_height + TopY + CellHeight + CellHeight * i * 5 );  //主体六根横线
          }

          DrawGrid(g, TopX, GridHeight * 4 + Title_height + TopY, ShiftX, CellHeight * 8 * 5 + CellHeight, 1, 2, pen_1);   //主体左侧温度脉博间竖线
          g.DrawLine(pen, TopX + ShiftX, TopY + GridHeight * 4 + Title_height, TopX + ShiftX, TopY + GridHeight * 4 + Title_height + CellHeight * 8 * 5 + CellHeight);//主体左侧边框线条加粗
          for (int i = 1; i <= 7; i++)
          {
              g.DrawString("上午", t_Font, Brushes.Black, ShiftX + TopX + CellWidth * (i - 1) * 6, TopY + GridHeight * 3 + 3);   //写上午
              g.DrawString("下午", t_Font, Brushes.Black, ShiftX + TopX + CellWidth * (i) * 6 - 3 * CellWidth, TopY + GridHeight * 3 + 3); //写下午
          }
           //写温度
           for(int i=1 ;i<=7;i++)
           {
               g.DrawString((42-i).ToString(),t_Font,Brushes.Black,ShiftX-30+TopX,70*i+TopY+92+CellHeight);   
               g.DrawString("°",t_Font,Brushes.Black,ShiftX-19+TopX,70*i+TopY+92+CellHeight);
           }
            //写脉博
            for(int i=1 ;i<=7;i++)
            {
                g.DrawString((180 - (i * 20)).ToString(), t_Font, Brushes.Red, TopX + 15, 70 * i + TopY + CellHeight + 92);
            }
            //画表尾
            DrawGrid(g, ShiftX + TopX, GridHeight * 4 + Title_height + TopY + CellHeight * 8 * 5 + CellHeight, Width - ShiftX - IMageright, Trail_height, 1, 7 * 6, pen_1);
            DrawGrid(g, TopX, GridHeight * 4 + Title_height + TopY + CellHeight * 8 * 5 + CellHeight, ShiftX, Trail_height, 1, 0, pen_1);
            DrawGrid(g, TopX, GridHeight * 4 + Title_height + TopY + CellHeight * 8 * 5 + Trail_height + CellHeight, ShiftX, GridHeight * 7, 7, 0, pen_1);
            DrawGrid(g, ShiftX + TopX, GridHeight * 4 + Title_height + TopY + CellHeight * 8 * 5 + Trail_height + CellHeight, Width - ShiftX - IMageright, GridHeight * 7, 7, 7, pen_1);
            DrawGrid(g, ShiftX + TopX, GridHeight * 4 + Title_height + TopY + CellHeight * 8 * 5 + Trail_height + CellHeight, Width - ShiftX - IMageright, GridHeight, 0, 14, pen_1);
            DrawGrid(g, TopX, GridHeight * 4 + Title_height + TopY + CellHeight * 8 * 5 + CellHeight, Width - IMageright, Trail_height, 1, 0, pen);//呼吸栏横线加粗
            return true;
        }
        public void DrawGrid(Graphics g,int x,int y,int width,int height,int row,int column,Pen pen)
        {
            //循环绘制多条横线 
            if (row>0)
            {
            for (int i = 0; i <=row; i++)         
            {

                g.DrawLine(pen, x, y+height/row * i, x+width, y+height/row*i);  
            }
            }

 
                //循环绘制多条竖线 
            if(column>0)
            {
                for (int i = 0; i <=column; i++)         
                {               
                    g.DrawLine(pen, x+width/column * i, y, x+width/column*i, y+height);         
                }
            }

        }
    }
}

